import Vue from 'vue'
import VueRouter from 'vue-router'
const Ele = () => import('../pages/Ele.vue')
const SongList = () => import('../pages/SongList.vue')
const PlayList = () => import('../pages/PlayList.vue')
const Play = () => import('../pages/Play.vue')
const Layout = () => import('../pages/Layout.vue')
const User = () => import('../pages/views/User.vue')
const Auth = () => import('../pages/views/Auth/Index.vue')

Vue.use(VueRouter)

const routes = [
  {
    path: '/ele',
    component: Ele
  },
  {
    path: '/',
    component: Layout,
    // 嵌套路由，大的组件中包含一个会变的组件
    children: [
      {
        path: 'user',
        component: User
      },
      {
        path: 'auth',
        component: Auth
      }
    ]
  },
  {
    path: '/list',
    component: SongList
  },
  {
    path: '/play/:id',
    component: PlayList
  },
  {
    path: '/listen/:id',
    component: Play
  },
  {
    path: '/about',
    name: 'About',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  // 公用的前缀，在所有的url地址上都有这个字段
  // base: 'aaa'  ,
  routes
})

export default router
